//base
function loadGltf3(){
    var wfslayer = "http://localhost:8090/geoserver/taiwan/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=taiwan:FWSL&maxFeatures=50&outputFormat=application%2Fjson";
    var scene = viewer.scene;
    $.ajax({
        url: wfslayer,
        dataType: 'json',
        type: 'GET',
        data:null,
        success: function(data, textStatus){
            //data可能是xmlDoc、jsonObj、html、text等等
            $.each(data.features,function(index,item){
               var lon = item.properties.Lon;
               var lat = item.properties.Lat;
               var name = item.properties.名称;
               var levels = item.properties.层数;
               var height = item.properties.高度;
               var fileName = item.properties.FileName;
                //fileName = fileName.split(".")[0];
                //alert(name);
                var modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(
                    Cesium.Cartesian3.fromDegrees(lon, lat, 1.0));        //gltf数据加载位置
                var model = scene.primitives.add(Cesium.Model.fromGltf({
                    url: 'http://localhost:9082/gltf2/ID_'+fileName+".gltf",        //如果为bgltf则为.bgltf
                    modelMatrix: modelMatrix
                    //scale : 3.0     //放大倍数
                }));
                var m = model.modelMatrix;
                //构建一个三阶旋转矩阵。模型旋转一定的角度，fromRotation[Z]来控制旋转轴，toRadians()为旋转角度，转为弧度再参与运算
                var m1 = Cesium.Matrix3.fromRotationZ(Cesium.Math.toRadians(-90));

                    //矩阵计算
                Cesium.Matrix4.multiplyByMatrix3(m, m1, m);
                //将计算结果再赋值给modelMatrix
                model.modelMatrix = m;
            });


        },
        error:function(XMLHttpRequest, textStatus, errorThrown){
            //通常情况下textStatus和errorThrown只有其中一个包含信息
            console.log(textStatus+errorThrown);
        }
    });




}

function loadTreeModel(){
    var wfslayer1 = "http://localhost:8090/geoserver/taiwan/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=taiwan:tree&maxFeatures=50&outputFormat=application%2Fjson";
    var scene = viewer.scene;

    var color = Cesium.Color.fromAlpha(Cesium.Color.GREEN, 0.5);
    $.ajax({
        url: wfslayer1,
        dataType: 'json',
        type: 'GET',
        data:null,
        success: function(data, textStatus){

            //data可能是xmlDoc、jsonObj、html、text等等
            $.each(data.features,function(index,item){
                var lon = item.properties.Lon;
                var lat = item.properties.Lat;
                var modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(
                    Cesium.Cartesian3.fromDegrees(lon, lat, 1.0));        //gltf数据加载位置
                var model = scene.primitives.add(Cesium.Model.fromGltf({
                    url: "http://localhost:9082/gltf2/tree4.gltf",        //如果为bgltf则为.bgltf
                    modelMatrix: modelMatrix,
                    color:color,
                    scale : 1.5     //放大倍数
                }));
                var m = model.modelMatrix;
                //构建一个三阶旋转矩阵。模型旋转一定的角度，fromRotation[Z]来控制旋转轴，toRadians()为旋转角度，转为弧度再参与运算
                var m1 = Cesium.Matrix3.fromRotationZ(Cesium.Math.toRadians(-90));

                //矩阵计算
                Cesium.Matrix4.multiplyByMatrix3(m, m1, m);
                //将计算结果再赋值给modelMatrix
                model.modelMatrix = m;
            });


        },
        error:function(XMLHttpRequest, textStatus, errorThrown){
            //通常情况下textStatus和errorThrown只有其中一个包含信息
            console.log(textStatus+errorThrown);
        }
    });

}